# 枪类
class Gun:
    def __init__(self, model):
        # 枪的类型
        self.model = model
        # 枪的子弹数量
        self.bullet_count = 0

    def add_bullet(self, count):
        # 装填子弹
        self.bullet_count += count

    def shoot(self):
        # 发射
        if self.bullet_count > 0:
            self.bullet_count -= 1
            print('发射子弹[子弹剩余:%d]' % self.bullet_count)
        else:
            print('[%s] 没有子弹了' % self.model)


AK47 = Gun('Ak47')

class Person:
    def __init__(self,name):
        self.name = name
        self.gun = None

    def fire(self):
        # 发射
        if self.gun:
            self.gun.add_bullet(10)
            self.gun.shoot()
        else:
            print('当前没有枪')

Ax = Person('Ax')
Ax.gun = AK47
Ax.fire()

